#
# This cmake script will build a basic Houdini DSO.
#
cmake_minimum_required(VERSION 2.6)

project(SOP_Star)

# run our helper process to grab the compile and link flags from hcustom
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/../hdk-config.py --notag --cmake=${CMAKE_BINARY_DIR}/FindHDK.cmake)

# now get the HDK definitions from the FindHDK.cmake module that was just generated
set(CMAKE_MODULE_PATH "${PROJECT_BINARY_DIR}")
find_package(HDK)
set(CMAKE_INSTALL_PREFIX "${HDK_HIH_DIR}")

# the project source code
set(SOP_Star_SRCS SOP_Star.C)

# setup to compile in the correct HDK environment
add_definitions(${HDK_DEFINITIONS})
include_directories(${HDK_INCLUDE_DIRS})
link_directories(${HDK_LIBRARY_DIRS})

# this command calls hdk-config.py to build a special file that will be the repository of the taginfo
add_custom_command(OUTPUT sesitag.C
                   DEPENDS ${SOP_Star_SRCS}
                   COMMAND ${PROJECT_SOURCE_DIR}/../hdk-config.py --tagfile=${CMAKE_BINARY_DIR}/sesitag.C)

if (APPLE)
    set(LTYPE MODULE)
else (APPLE)
    set(LTYPE SHARED)
endif (APPLE)

# this tells cmake to buid the DSO
add_library(SOP_Star ${LTYPE} ${SOP_Star_SRCS}  sesitag.C)

# houdini doesn't want the DSO to have "lib" as it's prefix
set_target_properties(SOP_Star PROPERTIES PREFIX "")

# unfortunately cmake's MODULE library type generates a ".so" file on OSX
if (APPLE)
    set_target_properties(SOP_Star PROPERTIES SUFFIX ".dylib")
endif (APPLE)

target_link_libraries(SOP_Star ${HDK_LIBRARIES})

# finally tell cmake where to put the results
install(TARGETS SOP_Star LIBRARY DESTINATION dso)
install(FILES SOP_star.png DESTINATION config/Icons)


